package collection;

import java.util.Arrays;
import java.util.List;

/** 数组转换为集合 */
public class ArrayToList {
    public static void main(String[] args) {
        String[] arr = {"one","two","three","four","five"};
        System.out.println("arr:"+ Arrays.toString(arr));
        List<String> list = Arrays.asList(arr);
        System.out.println(list);
        //对数组操作后,集合也会相应改变
        arr[1] = "six";
        System.out.println("arr:"+ Arrays.toString(arr));
        System.out.println(list);
        //对数组操作后,集合也会相应改变
        list.add(2,"seven");
        System.out.println("arr:"+ Arrays.toString(arr));
        System.out.println(list);
        //给集合添加/删除元素相当于给数组添加/删除元素
        //而数组是定长的,不会自动扩容/缩容,因此发生不支持异常
        list.add("132");//系统错误,不







    }



}
